home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Presen…tion Library 4 (Reseller) / Apple Ref. & Pres. Lib.v4.0.iso / 3-Presentations / Markets / Education / HyperCard In Education / HyperTree / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1990-04-02  |  8.0 KB  |  16 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>2</cardCount>
  7.     <cardID>3233</cardID>
  8.     <listID>3468</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>on domenu menu                       --// Added by Medior, Inc. 2/20/90
  17. global RPStackName
  18. if menu is in "Home,Quit HyperCard" and RPStackName is not empty then
  19. set cursor to watch
  20. put RPStackName into shortname
  21. repeat until offset(":",shortname) = 0
  22. delete char 1 to offset(":",shortname) of shortname
  23. end repeat
  24. delete last char of shortname
  25. answer "This will return to "&shortname&"." with "Cancel" or "OK"
  26. if it is "Cancel" then exit domenu
  27. set cursor to watch
  28. lock screen
  29. go RPStackName
  30. unlock screen with dissolve
  31. exit domenu
  32. else pass doMenu
  33. end domenu
  34.  
  35. on openStack
  36. defineStruct
  37. set the lineSize to 1
  38. set the pattern to 1
  39. show message at 22,300
  40. end openStack
  41.  
  42. on closeStack
  43. put empty into message
  44. set the pattern to 12
  45. end closeStack
  46.  
  47. on openCard
  48. global rootNode, searchPath, pathLength
  49. if the number of card fields > 0 then
  50. put the id of card field 1 into rootNode
  51. else
  52. put 0 into rootNode
  53. end if
  54. put empty into searchPath
  55. put 0 into pathLength
  56. walkTree
  57. end openCard
  58.  
  59. on deleteCard
  60. global searchPath, pathLength
  61. put empty into searchPath
  62. put 0 into pathLength
  63. end deleteCard
  64.  
  65. on closeCard
  66. undoPlot
  67. put empty into field treeList
  68. end closeCard
  69.  
  70. on defineStruct
  71. global rootRect, rootLoc, hSpacing, vSpacing, rootLevel
  72. put "241,148,271,163" into rootRect
  73. put "256,155" into rootLoc
  74. put "16,32,64,128" into hSpacing
  75. put "30,30,30,30" into vSpacing
  76. put 4 into rootLevel
  77. end defineStruct
  78.  
  79. on eraseTree
  80. global rootNode, seachPath, pathLength
  81. choose select tool
  82. drag from 0,0 to 512,342
  83. doMenu "Clear Picture"
  84. choose field tool
  85. repeat with i = the number of card fields down to 1
  86. click at the loc of card field i
  87. doMenu "Clear Field"
  88. end repeat
  89. put 0 into rootNode
  90. put empty into searchPath
  91. put 0 into pathLength
  92. choose browse tool
  93. end eraseTree
  94.  
  95. on initPlot targetNode
  96. global searchPath, pathLength
  97. undoPlot
  98. put targetNode into line 1 of searchPath
  99. put the loc of card field id targetNode into¬¨
  100. line 2 of searchPath
  101. put 2 into pathLength
  102. set the style of card field id targetNode to shadow
  103. set the lineSize to 2
  104. choose line tool
  105. end initPlot
  106.  
  107. on termPlot
  108. set the lineSize to 1
  109. choose browse tool
  110. end termPlot
  111.  
  112. on pathPlot targetNode
  113. global searchPath, pathLength
  114. if targetNode ‚↠0 then
  115. add 1 to pathLength
  116. put targetNode into line pathLength of searchPath
  117. add 1 to pathLength
  118. put the loc of card field id targetNode into¬¨
  119. line pathLength of searchPath
  120. set the style of card field id targetNode to shadow
  121. drag from line pathLength - 2 of searchPath to¬¨
  122. line pathLength of searchPath
  123. end if
  124. end pathPlot
  125.  
  126. on undoPlot
  127. global searchPath, pathLength
  128. if pathLength > 0 then
  129. choose line tool
  130. put line 1 of searchPath into targetNode
  131. set the style of card field id targetNode to rectangle
  132. put line 2 of searchPath into parentLoc
  133. put 3 into pathIndex
  134. repeat while pathIndex < pathLength
  135. put line pathIndex of searchPath into targetNode
  136. add 1 to pathIndex
  137. get line pathIndex of searchPath
  138. add 1 to pathIndex
  139. set the style of card field id targetNode to rectangle
  140. set the lineSize to 2
  141. drag from parentLoc to it with optionKey
  142. set the lineSize to 1
  143. drag from parentLoc to it
  144. put it into parentLoc
  145. end repeat
  146. put empty into searchPath
  147. put 0 into pathLength
  148. choose browse tool
  149. end if
  150. end undoPlot
  151.  
  152. function searchTree key
  153. global rootNode, rootLevel
  154. global parentSide, parentNode, parentLevel, targetNode
  155. put 0 into parentSide
  156. put 0 into parentNode
  157. put rootLevel + 1 into parentLevel
  158. if rootNode = 0 then
  159. put 0 into targetNode
  160. return "missing"
  161. else
  162. initPlot rootNode
  163. if key = line 1 of card field id rootNode then
  164. put rootNode into targetNode
  165. return "found"
  166. end if
  167. end if
  168. put rootNode into parentNode
  169. put rootLevel into parentLevel
  170. put 0 into targetNode
  171. repeat while true
  172. get line 1 of card field id parentNode
  173. if key < it then
  174. put 2 into parentSide
  175. get line 2 of card field id parentNode
  176. if it ‚↠0 then
  177. pathPlot it
  178. if key = line 1 of card field id it then
  179. put it into targetNode
  180. return "found"
  181. else
  182. put it into parentNode
  183. subtract 1 from parentLevel
  184. end if
  185. else
  186. return "missing"
  187. end if
  188. else
  189. if key > it then
  190. put 3 into parentSide
  191. get line 3 of card field id parentNode
  192. if it ‚↠0 then
  193. pathPlot it
  194. if key = line 1 of card field id it then
  195. put it into targetNode
  196. return "found"
  197. else
  198. put it into parentNode
  199. subtract 1 from parentLevel
  200. end if
  201. else
  202. return "missing"
  203. end if
  204. end if
  205. end if
  206. end repeat
  207. end searchTree
  208.  
  209. function newNode nodeLoc
  210. global rootRect
  211. choose field tool
  212. doMenu "New Field"
  213. get the number of card fields
  214. get the id of card field it
  215. set the rect of card field id it to rootRect
  216. set the loc of card field id it to nodeLoc
  217. set the style of card field id it to rectangle
  218. set the textFont of card field id it to geneva
  219. set the textSize of card field id it to 9
  220. set the textAlign of card field id it to center
  221. set the lockText of card field id it to true
  222. put 0 into line 2 of card field id it
  223. put 0 into line 3 of card field id it
  224. return it
  225. end newNode
  226.  
  227. function getNodeLoc parentSide, parentNode, parentLevel
  228. global rootLoc, hSpacing, vSpacing
  229. if parentNode = 0 then
  230. return rootLoc
  231. else
  232. put the loc of card field id parentNode into nodeLoc
  233. get item parentLevel of vSpacing
  234. add it to item 2 of nodeLoc
  235. get item parentLevel of hSpacing
  236. if parentSide = 2 then
  237. subtract it from item 1 of nodeLoc
  238. else
  239. add it to item 1 of nodeLoc
  240. end if
  241. return nodeLoc
  242. end if
  243. end getNodeLoc
  244.  
  245. function makeNode parentSide, parentNode, parentLevel
  246. global rootLoc
  247. if parentNode = 0 then
  248. get newNode( rootLoc )
  249. initPlot it
  250. return it
  251. else
  252. put getNodeLoc( parentSide, parentNode, parentLevel ) into nodeLoc
  253. get newNode( nodeLoc )
  254. put it into line parentSide of card field id parentNode
  255. choose line tool
  256. pathPlot it
  257. return it
  258. end if
  259. end makeNode
  260.  
  261. function insertNode key
  262. global rootNode, parentSide, parentNode, parentLevel
  263. get searchTree( key )
  264. if it = "found" then
  265. termPlot
  266. return "duplicate"
  267. end if
  268. if parentLevel = 0 then
  269. termPlot
  270. return "full"
  271. end if
  272. put makeNode( parentSide, parentNode, parentLevel ) into theNode
  273. put key into line 1 of card field id theNode
  274. if parentNode = 0 then put theNode into rootNode
  275. termPlot
  276. return "inserted"
  277. end insertNode
  278.  
  279. on moveSubTree parentSide, parentNode, parentLevel, nextNode
  280. if nextNode ‚↠0 then
  281. put the loc of card field id nextNode into oldLoc
  282. put getNodeLoc( parentSide, parentNode, parentLevel ) into newLoc
  283. set the loc of card field id nextNode to newLoc
  284. get line 2 of card field id nextNode
  285. if it ‚↠0 then
  286. drag from oldLoc to the loc of card field id it with optionKey
  287. moveSubTree 2, nextNode, parentLevel - 1, it
  288. end if
  289. get line 3 of card field id nextNode
  290. if it ‚↠0 then
  291. drag from oldLoc to the loc of card field id it with optionKey
  292. moveSubTree 3, nextNode, parentLevel - 1, it
  293. end if
  294. if parentNode ‚↠0 then
  295. drag from the loc of card field id parentNode to newLoc
  296. end if
  297. end if
  298. end moveSubTree
  299.  
  300. function removeNode parentSide, parentNode, parentLevel, targetNode
  301. global rootNode
  302. put line 1 of card field id targetNode into key
  303. if line 2 of card field id targetNode = 0 then
  304. put line 3 of card field id targetNode into nextNode
  305. else
  306. put line 2 of card field id targetNode into nextNode
  307. end if
  308. choose line tool
  309. if parentNode ‚↠0 then
  310. drag from the loc of card field id parentNode to¬¨
  311. the loc of card field id targetNode with optionKey
  312. set the lineSize to 1
  313. end if
  314. if nextNode ‚↠0 then
  315. drag from the loc of card field id targetNode to¬¨
  316. the loc of card field id nextNode with optionKey
  317. end if
  318. choose field tool
  319. click at the loc of card field id targetNode
  320. doMenu "Clear Field"
  321. if parentNode ‚↠0 then
  322. put nextNode into line parentSide of card field id parentNode
  323. end if
  324. if targetNode = rootNode then put nextNode into rootNode
  325. choose line tool
  326. moveSubTree parentSide, parentNode, parentLevel, nextNode
  327. return key
  328. end removeNode
  329.  
  330. on findNext
  331. global parentSide, parentNode, parentLevel, targetNode
  332. put "Looking for the successor to